package com.leng.nacos.controller;


import com.leng.nacos.domain.LUser;
import com.leng.nacos.service.IUserService;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class TestController {

    @Autowired
    private AmqpTemplate amqpTemplate ;

    @Autowired
    private IUserService userService ;

    @GetMapping("/test/{string}")
    public String test(@PathVariable String string) {
        amqpTemplate.convertAndSend("myQueue",string);
        return "Hello Nacos :" + string;
    }
    @GetMapping("/test2/{string}")
    public String test(@PathVariable Integer string) {
        amqpTemplate.convertAndSend("myQueue",string);
        return "Hello Nacos :" + string;
    }

    @PostMapping("/test/add")
    public String add(@RequestBody LUser user){
        boolean save = userService.save(user);
        return save?"成功":"失败" ;
    }

    @GetMapping("/query")
    public LUser query(String a){
        return userService.getThisOne(a);
    }
}
